﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>预筛选记录</title>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>
<body class="iframeBody">
<div class="Wrapper">
    <div id="pageInTab" class="pageInTab"/>
    <div tabid="tabA" title="预筛选列表" lselected="true">
    <div class="searchArea">
        <form id="searchBar">
            <div class="fieldset1 clearFix">
                <div class="fieldBox col_33">
                    <div class="label">筛选记录id</div>
                    <div class="field">
                        <input name="id" id="id" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">客户</div>
                    <div class="field">
                        <input name="cstNm" id="cstNm" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">客户经理名称</div>
                    <div class="field">
                        <input name="cstMgrNm" id="cstMgrNm" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="clearFix"></div>
                <div class="fieldBox col_40" >
                    <div class="label">创建时间  </div>
                    <div class="field">
                        <input name="crtTmStart" id="crtTmStart" type="text" class="ui-datepicker" value="">
                        <span>--</span>
                        <input name="crtTmEnd" id="crtTmEnd" type="text" class="ui-datepicker" value="">
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">状态</div>
                    <div class="field">
                        <select name="insSts" id="insSts">
                            <option value=" " selected="selected">--请选择--</option>
                            <option value="0">筛选中</option>
                            <option value="1">未占用</option>
                            <option value="2">已占用</option>
                        </select>
                    </div>
                </div>
                <div class="clearFix"></div>
                <div class="btnsBox">
                    <span id="searchBtn" class="sq-button sq-button-round">查询</span>
                    <span id="clearBtn" onclick="clearBtn();" class="sq-button sq-button-round">清空</span>
                    <span id="addBtn" onclick="addBtn();" class="sq-button sq-button-round">新增</span>
                </div>
            </div>
        </form>
    </div>
    </div>
    <div id="routeListTab" class="sq-grid"></div>
</div>
<script type="text/javascript">
    var grid_routeList;
    $(function () {
        initList();
    })
    function toDetailPage(routeId) {
        var timestamp=new Date().getTime();
        Add_navTab('tab_prj_bsc_info_add'+timestamp,'预筛选记录详情','<%=path%>/preinsroute/preRouteBscInfo/toModifyPage.do?id=' + routeId +'&editFlag=false');
    }
    function addBtn(){
        var callback = function(){
            grid_routeList.reload();
        }
        var timestamp=new Date().getTime();
        Add_navTab('tab_prj_bsc_info_add'+timestamp,'添加预筛选信息','<%=path%>/preinsroute/preRouteBscInfo/toModifyPage.do',callback);
    }
    function initList(){
        grid_routeList = $("#routeListTab").ligerGrid({
            url: '<%=path%>/preinsroute/preRouteBscInfo/initList.do',
            method : 'get',
            parms:{
                id:$("#id").val(),
                cstNm:$("#cstNm").val(),
                cstMgrNm:$("#cstMgrNm").val(),
                crtTmStart:$("#crtTmStart").val(),
                crtTmEnd:$("#crtTmEnd").val(),
                insSts:$("#insSts").val()
            },
            columns: [
                { display: '筛选记录id', name: 'id', align:'left',minWidth: 140,
                    render:function(rowdata){
                        return '<a href="#" onclick="toDetailPage('+rowdata.id+')">' + rowdata.cstNm + rowdata.id + '</a>';
                    }
                },
                { display: '客户', name: 'cstNm', minWidth: 140,align:'center', enabledSort:true},
                { display: '客户经理', name: 'cstMgrNm', minWidth: 140,align:'center', enabledSort:true},
                { display: '创建时间', name: 'crtTm', width: 100 , enabledSort:true,render:renderDate},
                { display: '数据来源', name: 'dsCd',minWidth: 140, enabledSort:true,
                    render:function (rowdata) {
                        if(rowdata.dsCd == 'CHL0001'){
                            return "融资租赁后台管理";
                        }else if(rowdata.dsCd == 'CHL0008'){
                            return "狮桥助手APP";
                        }
                    }
                },
                { display: '状态', name: 'insSts', minWidth: 60 , enabledSort:true,
                    render:function(rowdata){
                        if(rowdata.insSts == 0){
                            return "筛选中";
                        }
                        if(rowdata.insSts == 1){
                            return "未占用";
                        }
                        if(rowdata.insSts == 2){
                            return "已占用";
                        }
                    }
                },
                { display: '操作', name: 'actions', minWidth: 100 , enabledSort:true,
                    render: function (rowdata, rowindex, value){
                        if (rowdata.insSts == 1){
                            var h="";
                            h+='<a class="sq-button-hasicon" href="javascript:modifyPreRouteInfo(';
                            h+="'"+rowdata.id+"'";
                            h+=')"><i class="sqBtnIco_4"></i>修改</a>';
                            var j="";
                            j+='<a class="sq-button-hasicon" href="javascript:removePreRouteInfo(';
                            j+="'"+rowdata.id+"'";
                            j+=')"><i class="sqBtnIco_7"></i>删除</a>';
                            return h + j ;
                        }else{
                            return "" ;
                        }
                    }
                }
            ],
            page:1,
            pageSize:10,
            root:'rows',
            record:'total',
            hideLoadButton : true,
            width: '100%',
            height:'100%',
            rownumbers:true
        });
        $("#searchBar").ligerForm();
        $("#pageloading").hide();
    }
    $("#searchBtn").click(function (event) {
        var id = $("#id").val();
        var cstNm = $("#cstNm").val();
        var cstMgrNm = $("#cstMgrNm").val();
        var crtTmStart = $("#crtTmStart").val();
        var crtTmEnd = $("#crtTmEnd").val();
        var insSts = $("#insSts").val();
        grid_routeList.setParm("id", id);
        grid_routeList.setParm("cstNm", cstNm);
        grid_routeList.setParm("cstMgrNm", cstMgrNm);
        grid_routeList.setParm("crtTmStart", crtTmStart);
        grid_routeList.setParm("crtTmEnd", crtTmEnd);
        grid_routeList.setParm("insSts", insSts);
        grid_routeList.reload();
    });
    var clearBtn = function () {
        $("#id").val("");
        $("#cstNm").val("");
        $("#cstMgrNm").val("");
        $("#crtTmStart").val("");
        $("#crtTmEnd").val("");
        $("#insSts").val("");
    }
    function removePreRouteInfo(id) {
        $.ajax({
            type: 'get',
            dataType:'json',
            data: "",
            url: '<%=path%>/preinsroute/preRouteBscInfo/removeById.do?id='+id,
            success:function(msg){
                if(msg.success == 1){
                    initList();
                }else{
                    $.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
                }
            }
        });
    }
    function modifyPreRouteInfo(id) {
        var timestamp=new Date().getTime();
        Add_navTab('tab_prj_bsc_info_add'+timestamp,'修改预筛选信息','<%=path%>/preinsroute/preRouteBscInfo/toModifyPage.do?id='+id+'&editFlag=true');
    }
    //格式化时间
    function renderDate(rowdata, index, value){
        var dateStr = "";
        if(null != value){
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
        }
        return dateStr;
    }
</script>
</body>
</html>
